<?php
// +-------------------------------------------------------------------
// |
// +-------------------------------------------------------------------
// | Copyright (c) 2009-2016 All rights reserved.
// +-------------------------------------------------------------------
namespace Service\Api\V1;

class UserInfo
{
    public $login = true; //是否需要登录才能访问该接口
    public $title = "用户信息";
    public $group = '用户';
    public $desc = "";

    public $input = [
    ];

    public $output = [
        'total_contribution' => 'label=贡献值;',
        'avatar_url' => 'label=头像地址;',
        'username' => 'label=用户名;',
        'real_name' => 'label=真实姓名;',
        'nickname' => 'label=昵称;',
        'sex' => 'label=性别;',
        'sex_label' => 'label=性别;',
        'eyes_coupon' => 'label=护眼测试券;',
        'eyes_money' => 'label=护眼鲸币;',
        'hy_num' => 'label=护眼次数;',
        'eyes_archives_num' => 'label=护眼档案条数;',
        'is_archives' => 'label=自己是否有档案:1是2否;',
    ];

    public function run($param, $uid)
    {
        $result = OE('user')->getDetail($uid);
        $flag = M('eyes_archives')->where(['relation' =>1,'userid' => $uid])->find();
        if($flag) {
            $result['is_archives'] = 1;
        }else{
            $result['is_archives'] = 2;
        }
        $ret1 = M('eyes_archives_vision')->where(['relation' =>1,'userid' => $uid])->count();
        $result['hy_num'] = $ret1?$ret1:0;
        $ret1 = M('eyes_archives')->where(['userid' => $uid])->count();
        $result['eyes_archives_num'] = $ret1?$ret1:0;
        return $result;
    }
}
